<template>
  <div>
    <el-row>
      <el-button type="primary" @click="test01">测试接口加签与验签(路径参数)</el-button>
      <el-button type="primary" @click="test02">测试接口加签与验签(请求体参数)</el-button>
    </el-row>
  </div>
</template>

<script>
import {get,postJson} from "@/common/js/axios"
export default {
    mounted() {
      get("/sign",{money: 20.3}).then(res => {
        if ('code' in res) {
          this.$ls.set('PUBLIC_KEY', res.data.publicKey);
          console.log("publicKey: ", res.data.publicKey)
          this.$message({
            showClose: true,
            message: '获取公钥成功'
          });
        }
        
      });
    },
    methods: {
      test01() {
        get("/sign/t01",{money: 20.3}).then(res => {
          if ('code' in res) {
            console.log(res);
            this.$message({
              showClose: true,
              message: 'success'
            });
          }
          
        });
        
      },

      test02() {
        postJson("/sign/t02",{money: 20.3, bankCard: "test"}).then(res => {
          if ('code' in res) {
            console.log(res);
            this.$message({
              showClose: true,
              message: 'success',
              type: 'success'
            });
          }
          
        });
      },

      open3() {
        this.$message({
          showClose: true,
          message: '警告哦，这是一条警告消息',
          type: 'warning'
        });
      },

      open4() {
        this.$message({
          showClose: true,
          message: '错了哦，这是一条错误消息',
          type: 'error'
        });
      }
    }
  }
</script>

<style>

</style>